<?php
/**
 * @author cik
 *
 */
class Score_TotalController extends Zend_Controller_Action
{
    /**
     * 教師流水號
     * @var integer
     */
    private $_teacherSn;

    public function init()
    {
        $this->_teacherSn = Teacher_Model_Teacher::getSnById();

    }


    /**
     * @return unknown_type
     */
    public function indexAction()
    {
        // 取出任教班級
        if ($classNum = Teacher_Model_Teacher::getTutorClass()) {
            // 取出班級階段成績資料
            $statistics = new Score_Model_Statistics($classNum);
            // 成績設定
            $this->view->examineSetup = $statistics->getExamineSetup();
            // 目前階段
            //            $this->view->currStage = $statistics->getCurrStage();
        }
        else
        $this->render('noPerm');
    }

    /**
     * 成績列表
     * @return unknown_type
     */
    public function getScoreAction()
    {
        $this->getHelper('layout')->disableLayout();
        $classNum = Teacher_Model_Teacher::getTutorClass();
        // 取出班級階段成績資料
        $statistics = new Score_Model_Statistics($classNum);
        $stage = (int) $this->getRequest()->getParam('stage',0);
        if ($stage == 0)
        throw new Score_Model_Exception('Error stage id');
        // 加計平時成績
        $plusCount = (int)$this->getRequest()->getParam('plusCount');
        // 加權計算
        $rateCount = (int)$this->getRequest()->getParam('rateCount');

        $this->view->rateCount = $rateCount;
        //學生成績
        $this->view->studentScore = $statistics->getStudentScore($stage,$plusCount,$rateCount);
        // 課程名稱
        $this->view->subject = $statistics->getSubject();

    }

    /**
     * 友善列印
     * @return unknown_type
     */
    public function printScoreAction()
    {
         $this->getHelper('layout')->disableLayout();
        $classNum = Teacher_Model_Teacher::getTutorClass();
        // 取出班級階段成績資料
        $statistics = new Score_Model_Statistics($classNum);
        $stage = (int) $this->getRequest()->getParam('stage',0);
        if ($stage == 0)
        throw new Score_Model_Exception('Error stage id');

        $this->view->className = $statistics->getClassName();
        // 階段
        $this->view->stage = $stage;
        // 加計平時成績
        $plusCount = (int)$this->getRequest()->getParam('plusCount');
        // 加權計算
        $rateCount = (int)$this->getRequest()->getParam('rateCount');
        // 列印簽章
        $this->view->signPrint = (int)$this->getRequest()->getParam('signPrint');
        // 列印名次
        $this->view->rankPrint = (int)$this->getRequest()->getParam('rankPrint');

        $this->view->plusCount = $plusCount;

        $this->view->rateCount = $rateCount;
        //學生成績
        $this->view->studentScore = $statistics->getStudentScore($stage,$plusCount,$rateCount);
        // 課程名稱
        $this->view->subject = $statistics->getSubject();
    }



}

